package com.dog.basics.admin.controller.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.common.PcFeedbackHandleDto;
import com.dog.basics.bean.dto.admin.common.PcFeedbackPageDto;
import com.dog.basics.bean.vo.admin.common.PcFeedbackPageVo;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.common.IDogFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 意见 前端控制器
 * </p>
 *
 * @author fengjukang
 * @since 2019-10-11
 */
@RestController
@Api(value = SwaggerConstants.COMMON+"意见反馈",tags =SwaggerConstants.COMMON+"意见反馈")
@RequestMapping("/admin/feedback")
@AllArgsConstructor
public class PcFeedbackController {

    private final IDogFeedbackService feedbackService;

    /**
     * @功能描述: 意见反馈列表
     * @author He
     * @date 2020/5/22
     */
    @ApiOperation(value = "意见反馈列表",notes = "意见反馈列表(admin:page:get)")
    @PreAuthorize("@pms.hasPermission('admin:page:get')")
    @GetMapping("/page")
    public R<IPage<PcFeedbackPageVo>> getFeedbackPage(PageParam page, PcFeedbackPageDto dto){
        return R.ok(feedbackService.getFeedbackPage(page, dto));
    }


    /**
     * @功能描述: 删除意见反馈
     * @author He
     * @date 2020/5/22
     */
    @ApiOperation(value = "删除意见反馈",notes = "删除意见反馈 (admin:feedback:del)")
    @ApiImplicitParam(name = "ids",value = "意见标识Ids",dataType = "List<Long>",required = true)
    @PreAuthorize("@pms.hasPermission('admin:feedback:del')")
    @DeleteMapping
    public R<Boolean> delFeedback(@RequestBody List<Long> ids){
        return R.ok(feedbackService.delFeedback(ids));
    }


    /**
     * @功能描述: 意见处理
     * @author He
     * @date 2020/5/22
     */
    @ApiOperation(value = "意见处理",notes = "意见处理 (admin:feedback:put)")
    @PreAuthorize("@pms.hasPermission('admin:feedback:put')")
    @PutMapping
    public R<Boolean> editFeedback(@RequestBody @Valid PcFeedbackHandleDto dto){
        return R.ok(feedbackService.editFeedback(dto));
    }

}
